package com.archie.xunji;

import android.app.Activity;
import android.graphics.Color;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class SpannableStringDemoActivity extends Activity {
    private TextView tv_TextView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spannable_string_demo);

        tv_TextView = (TextView) findViewById(R.id.tv_TextView);
        SpannableString spannableString = new SpannableString("这是一段spannableString文本");
        spannableString.setSpan(new BackgroundColorSpan(Color.GRAY),0,3, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        spannableString.setSpan(new ForegroundColorSpan(Color.RED),5,7,Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv_TextView.append(spannableString);

    }

}
